feat: add Tron payment processor support#1690
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughAdds TRON network support to the SDK's payment processing pipeline. Includes TRON TRC20 utility functions, fee proxy payment workflows, integration with payment detection layer, and comprehensive test coverage. Also updates CI/CD configuration to wait for Graph node readiness before deployment. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User/Client
participant Processor as Payment Processor
participant TronWeb as TronWeb Library
participant TronNet as TRON Network
participant Contract as ERC20 Fee Proxy Contract
User->>Processor: payTronFeeProxyRequest(request, tronWeb)
Processor->>Processor: Validate TRON network support
Processor->>Processor: Validate request & extract payment info
Processor->>TronWeb: getTronAllowance(tokenAddress)
TronWeb->>Contract: Read allowance
Contract-->>TronWeb: Current allowance
TronWeb-->>Processor: Allowance value
alt Insufficient Allowance
Processor->>Processor: Compute total amount (payment + fee)
Processor->>TronWeb: approveTrc20(tokenAddress, amount)
TronWeb->>Contract: approve(proxyAddress, amount)
Contract-->>TronWeb: Approval transaction result
TronWeb-->>Processor: Transaction ID
Processor->>TronNet: Wait for confirmation
TronNet-->>Processor: Confirmed
end
Processor->>TronWeb: isTronAccountSolvent(tokenAddress, totalAmount)
TronWeb->>Contract: balanceOf(senderAddress)
Contract-->>TronWeb: Balance
TronWeb-->>Processor: Solvent status
Processor->>TronWeb: processTronFeeProxyPayment(...)
TronWeb->>Contract: transferFromWithReferenceAndFee(...)
Contract-->>TronWeb: Payment transaction result
TronWeb-->>Processor: Transaction ID
Processor->>TronNet: Wait for confirmation
TronNet-->>Processor: Confirmed
Processor-->>User: Payment completion result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile OverviewGreptile SummaryAdded comprehensive Tron blockchain payment support to the payment-processor package, enabling TRC20 token payments through the ERC20 Fee Proxy contract. Key Changes:
Implementation Details:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant TronFeeProxy as tron-fee-proxy.ts
participant UtilsTron as utils-tron.ts
participant TronWeb
participant TRC20Contract as TRC20 Token
participant ProxyContract as ERC20FeeProxy
Note over Client,ProxyContract: Approval Flow
Client->>TronFeeProxy: approveTronFeeProxyRequest(request, tronWeb)
TronFeeProxy->>TronFeeProxy: Validate network (TronChains)
TronFeeProxy->>TronFeeProxy: Calculate total amount (payment + fee)
TronFeeProxy->>UtilsTron: approveTrc20(tronWeb, tokenAddress, network, amount)
UtilsTron->>UtilsTron: getERC20FeeProxyAddress(network)
UtilsTron->>TronWeb: contract(TRC20_ABI, tokenAddress)
TronWeb-->>UtilsTron: TRC20 contract instance
UtilsTron->>TRC20Contract: approve(proxyAddress, amount).send()
TRC20Contract-->>UtilsTron: Transaction result
UtilsTron->>UtilsTron: callback.onHash(txHash)
UtilsTron-->>TronFeeProxy: txHash
TronFeeProxy-->>Client: txHash
Note over Client,ProxyContract: Payment Flow
Client->>TronFeeProxy: payTronFeeProxyRequest(request, tronWeb)
TronFeeProxy->>TronFeeProxy: Validate network (TronChains)
TronFeeProxy->>TronFeeProxy: validateRequest(ERC20_FEE_PROXY_CONTRACT)
TronFeeProxy->>TronFeeProxy: getRequestPaymentValues()
TronFeeProxy->>TronFeeProxy: validatePaymentReference()
TronFeeProxy->>UtilsTron: isValidTronAddress(paymentAddress)
UtilsTron-->>TronFeeProxy: validation result
TronFeeProxy->>UtilsTron: getTronAllowance(tronWeb, tokenAddress, network)
UtilsTron->>TronWeb: contract(TRC20_ABI, tokenAddress)
TronWeb-->>UtilsTron: contract instance
UtilsTron->>TRC20Contract: allowance(owner, spender).call()
TRC20Contract-->>UtilsTron: allowance amount
UtilsTron-->>TronFeeProxy: BigNumber allowance
alt Insufficient Allowance
TronFeeProxy-->>Client: Error: Insufficient TRC20 allowance
end
TronFeeProxy->>UtilsTron: isTronAccountSolvent(tronWeb, tokenAddress, amount)
UtilsTron->>TronWeb: contract(TRC20_ABI, tokenAddress)
TronWeb-->>UtilsTron: contract instance
UtilsTron->>TRC20Contract: balanceOf(owner).call()
TRC20Contract-->>UtilsTron: balance
UtilsTron-->>TronFeeProxy: true/false
alt Insufficient Balance
TronFeeProxy-->>Client: Error: Insufficient TRC20 token balance
end
TronFeeProxy->>UtilsTron: processTronFeeProxyPayment(params)
UtilsTron->>UtilsTron: Validate all addresses
UtilsTron->>UtilsTron: getERC20FeeProxyAddress(network)
UtilsTron->>TronWeb: contract(ERC20_FEE_PROXY_ABI, proxyAddress)
TronWeb-->>UtilsTron: proxy contract instance
UtilsTron->>UtilsTron: Format payment reference (add 0x prefix)
UtilsTron->>ProxyContract: transferFromWithReferenceAndFee(token, to, amount, ref, feeAmount, feeAddress).send()
ProxyContract->>TRC20Contract: transferFrom(payer, recipient, amount)
TRC20Contract-->>ProxyContract: success
alt Fee > 0
ProxyContract->>TRC20Contract: transferFrom(payer, feeRecipient, feeAmount)
TRC20Contract-->>ProxyContract: success
end
ProxyContract-->>UtilsTron: Transaction result
UtilsTron->>UtilsTron: callback.onHash(txHash)
UtilsTron-->>TronFeeProxy: txHash
TronFeeProxy-->>Client: txHash
|
853297e to
5bb6ef7
Compare
5ac332a to
984a642
Compare
3c7d77f to
816af51
Compare
984a642 to
41e33e8
Compare
816af51 to
fc1128c
Compare
41e33e8 to
d03f1db
Compare
fc1128c to
cf070e9
Compare
d03f1db to
7d73139
Compare
cf070e9 to
62f2685
Compare
6dce563 to
dbed330
Compare
3bf2428 to
f06892c
Compare
1797a69 to
d5e25df
Compare
f06892c to
8456f0a
Compare
b5ce760 to
60d3c03
Compare
MantisClone
left a comment
There was a problem hiding this comment.
Looks good to me so far.
Reviewed with Claude Code Opus 4.5
MantisClone
left a comment
There was a problem hiding this comment.
LGTM — well-typed TronWeb interface, good validation (address format, balance, allowance). One minor non-blocking comment about fee limits (see inline).
cecfc7e to
6c8cb20
Compare
ceec59f to
10ddce5
Compare
6c8cb20 to
938afca
Compare
10ddce5 to
362dbbc
Compare
938afca to
c8c4b67
Compare
5ec56fe to
b8f3840
Compare
b8f3840 to
55c4451
Compare
1408a38 to
559e872
Compare
55c4451 to
2d1ffbc
Compare
559e872 to
96f878e
Compare
91553a4 to
8315931
Compare
96f878e to
35cc88d
Compare
Merge activity
|
- Add tron-fee-proxy payment functions - Add Tron utility functions for transaction handling - Add unit tests for Tron payment processing - Update request-client tests for Tron support
Add a retry loop to wait for the Graph node to be ready on port 8020 before attempting to create and deploy the subgraph.
- Introduce DEFAULT_TRON_APPROVAL_FEE_LIMIT and DEFAULT_TRON_PAYMENT_FEE_LIMIT constants for TRC20 transactions. - Update approveTrc20 and processTronFeeProxyPayment functions to use dynamic fee limits instead of hardcoded values.
- Update ERC20FeeProxyPaymentDetector to support TronChainName by adding TronInfoRetriever. - Enhance the getTheGraphInfoRetriever method to handle Tron payment chains.
- Change import statement for TronInfoRetriever to reflect new file structure in the tron directory.
8315931 to
700e046
Compare

Description of the changes
Added support for Tron blockchain payments in the payment-processor package. This implementation enables TRC20 token payments through the ERC20 Fee Proxy contract on Tron networks.
The changes include:
New
tron-fee-proxy.tsmodule with functions for paying requests on Tron:payTronFeeProxyRequest- Process payments with TRC20 tokensapproveTronFeeProxyRequest- Approve token spendinghasSufficientTronAllowance- Check token allowancehasSufficientTronBalance- Verify token balancegetTronPaymentInfo- Get payment detailsNew
utils-tron.tsmodule with Tron-specific utilities:Comprehensive test coverage for all new functionality
Exports for the new modules in the package index
Closes RequestNetwork/private-issues#234
Summary by CodeRabbit